package com.lmf.mvc.controller;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller     //必须使用这个控制注解，其他三个注册bean的注解不管用
//@Component    //不管用
public class ControllerDemo {

    @RequestMapping(value = {"/","index.do"},
            method = {RequestMethod.GET,RequestMethod.POST})
    public String getIndex(){
        return "index";
    }

    @RequestMapping(value = "/two",params = {"username=root","password=123456"})
    public String getTwo(){
        return "two";
    }

    @RequestMapping(value = "/two/{id}",
            params = {"username=root","password=123456"},
            headers = "host=localhost:8080")
    public String getTwo_2(@PathVariable("id") Integer id){
        return "two";
    }
}
